package com.hqyj.dao;

import com.hqyj.entity.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Repository
public interface UserDao extends JpaRepository<User,Integer> {


//修改销售人员
@Transactional
@Modifying
  @Query(value = "update user set account = :#{#user.account}, password = :#{#user.password}, name = :#{#user.name}, sex= :#{#user.sex},phone=:#{#user.phone} where id = :#{#user.id}",nativeQuery = true)
  int updateById(@Param("user") User user);


//查询销售人员

  @Query(value = "select * from user where role_id=2",nativeQuery = true)
  Page<User> QueryAll(Pageable pageable );


}
